package com.example.sisko_database;

import java.io.IOException;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class DatabaseDelete {

	private DatabaseInit myDbHelper;
	private SQLiteDatabase database;
	
	//opening the database
	public DatabaseDelete(Context context) {
		
		myDbHelper = new DatabaseInit(context);
	
		try {
		  
			myDbHelper.createDataBase();
		
		} catch (IOException ioe) {
	
			throw new Error("Unable to create database");
		  
		}
		  
		try {
		  
			database = myDbHelper.openDataBase();
		
		  
		}catch(SQLException sqle){
		  
			throw sqle;
		 
		}
	}
	
	//closing the database
	public void close(){
		database.close();
	}
	
	//delete one column in TABLE_CONTACT
	public void deleteColumnContact(int contact_id){
		
		database.delete("TABLE_CONTACT", "contact_id" + "=" + "\"" + contact_id + "\"", null);

	}
	
	//delete one column in TABLE_RATING
	public void deleteColumnRating(int rating_id){
		
		database.delete("TABLE_RATING", "rating_id" + "=" + "\"" + rating_id + "\"", null);

	}
	
	//delete one column in TABLE_LOCATION
	public void deleteColumnLocation(int loc_id){
		
		database.delete("TABLE_LOCATION", "loc_id" + "=" + "\"" + loc_id + "\"", null);

	}
	
}
